﻿Imports System.ServiceModel
Imports System.ServiceModel.Web
Imports System.ServiceModel.Description
Imports System.Runtime.Serialization
Imports VPager.Display.PagerDisplay
Imports VPager.Enumerations

Namespace WebService

    ''' <summary>
    ''' The ServiceStatus class is a simple data container that holds the current service status
    ''' information and values.  The values are managed/maintained by the Controller class.
    ''' Each Status has both a Public and a Private Property definition.  The public properties
    ''' are the primary means to set/get the state information using Enumerated types. The
    ''' private methods exist only to assist the WCF serialization so that the Enumerated Type
    ''' "string" values are serialized and not the numeric (ordinal position) values used by
    ''' default.  For instance HealthState.NORMAL will now serialize to "NORMAL" instead of
    ''' the default integer of 0.
    ''' </summary>
    ''' <remarks></remarks>
    <DataContract()> _
    Public Class ServiceStatus

        Private overall_status As HealthState = HealthState.UNKNOWN
        Private network_status As HealthState = HealthState.UNKNOWN
        Private display_state As AbledState = AbledState.DISABLED
        Private display_mode As MonitorMode = MonitorMode.UNKNOWN


        Public Property OverallStatus() As HealthState
            Get
                Return overall_status
            End Get
            Set(ByVal value As HealthState)
                overall_status = value
            End Set
        End Property

        ' Used only for Web Serialization
        <DataMember(Name:="OverallStatus")> _
        Private Property _OverallStatus() As String
            Get
                Return overall_status.ToString
            End Get
            Set(ByVal value As String)
                ' Ignore required by Serializer
            End Set
        End Property

        Public Property NetworkStatus() As HealthState
            Get
                Return network_status
            End Get
            Set(ByVal value As HealthState)
                network_status = value
            End Set
        End Property

        ' Used only for Web Serialization
        <DataMember(Name:="NetworkStatus")> _
        Private Property _NetworkStatus() As String
            Get
                Return network_status.ToString
            End Get
            Set(ByVal value As String)
                ' Ignore required by Serializer
            End Set
        End Property

        Public Property DisplayState() As AbledState
            Get
                Return display_state
            End Get
            Set(ByVal value As AbledState)
                display_state = value
            End Set
        End Property

        ' Used only for Web Serialization
        <DataMember(Name:="DisplayState")> _
        Private Property _DisplayState() As String
            Get
                Return display_state.ToString
            End Get
            Set(ByVal value As String)
                ' Ignore required by Serializer
            End Set
        End Property

        Public Property DisplayMode() As MonitorMode
            Get
                Return display_mode
            End Get
            Set(ByVal value As MonitorMode)
                display_mode = value
            End Set
        End Property

        ' Used only for Web Serialization
        <DataMember(Name:="DisplayMode")> _
        Private Property _DisplayMode() As String
            Get
                Return display_mode.ToString
            End Get
            Set(ByVal value As String)
                ' Ignore required by Serializer
            End Set
        End Property

        Overrides Function ToString() As String
            Dim rv As String = "(OverallStatus=" + Me.OverallStatus +
                               ", NetworkStatus=" + Me.NetworkStatus +
                               ", DisplayStatus=" + Me.DisplayState + ")"
            Return rv
        End Function
    End Class

End Namespace
